package week4;

public class StringIsImmutable {
	public static void main(String[] args) {
		String x = "Hello";
		String y = "GoodBye";

		System.out.println("   String x has " + x + " and hashcode: " + x.hashCode());
		System.out.println("   String y has " + y + " and hashcode: " + y.hashCode());

		int p = x.indexOf('a');
		System.out.println("After x.indexOf('a') == " + p);
		System.out.println("   String x has " + x + " and hashcode: " + x.hashCode());

		x = x + y;
		System.out.println("After + operation:");
		System.out.println("   String x has " + x + " and hashcode: " + x.hashCode());

		x = x.concat("Something");
		System.out.println("After x.concat:");
		System.out.println("   String x has " + x + " and hashcode: " + x.hashCode());

		p = x.indexOf('t');
		System.out.println("After x.indexOf('t') == " + p);
		System.out.println("   String x has " + x + " and hashcode: " + x.hashCode());
	}
}
